import request from '@/utils/request'
import { TigerType , AircraftType, SweepType , MineGameType, LuckType , BattleRoyaleType } from '@/views/setting/gameConfig/gameDataConversion'

// API接入配置列表
export const getDockingList = (params: any) => {
  return request.get('/v1/merchant/setting/dockingList', { params: params })
}

// API接入配置编辑
export const putChangeDocking = (params: any) => {
  return request.put('/v1/merchant/setting/changeDocking', params)
}

// 生成秘钥秘钥
export const postSystemFandKey = (data: any) => {
  return request.post('/v1/merchant/system/randKey', data)
}

// 游戏配置列表  
export const getGameConfigList = (params: any) => {
  return request.get('/v1/merchant/config/getGameList', { params: params })
}

// 查询-老虎机游戏状态  
export const getGameStatus = (data: any) => {
  return request.post('/v1/merchant/config/getNowGameStatus', data)
}
// 获取游戏老虎机配置  
export const getOperatorTiger = (params: any) => {
  return request.get('/v1/merchant/config/getSlotGameConfig', { params: params }).then((res) => {
    res.data = new TigerType().apiLocal(res.data)
    return res
  })
}
// 修改游戏老虎机配置  
export const editTiger = (data: any) => {
  data = new TigerType().localApi(data)
  return request.post('/v1/merchant/config/updateSlotGameConfig', data)
}

// 获取游戏百人飞机配置  
export const getHundredConfig = (params: any) => {
  return request.get('/v1/merchant/config/getHundredConfig', { params: params }).then((res) => {
    // 飞机
    if(params.game_id == 100001){
      res.data = new AircraftType().apiLocal(res.data)
    }
    // 大逃杀
    if(params.game_id == 100002){
      res.data = new BattleRoyaleType().apiLocal(res.data)
    }
    // Luck49
    if(params.game_id == 100003){
      res.data = new LuckType().apiLocal(res.data)
    }
    return res
  })
}
// 修改游戏百人飞机配置  
export const updateHundredConfig = (data: any) => {
  // 飞机
  if(data.game_id == 100001){
    data = new AircraftType().localApi(data)
  }
  // 大逃杀
  if(data.game_id == 100002){
    data = new BattleRoyaleType().localApi(data)
  }
  // Luck49
  if(data.game_id == 100003){
    data = new LuckType().localApi(data)
  }
  return request.post('/v1/merchant/config/updateHundredConfig', data)
}

// 获取游戏扫雷配置  
export const getMineConfig = (params: any) => {
  return request.get('/v1/merchant/config/getMineConfig', { params: params }).then((res) => {
    res.data = new SweepType().apiLocal(res.data)
    return res
  })
}
// 修改游戏扫雷配置  
export const updateMineConfig = (data: any) => {
  data = new SweepType().localApi(data)
  return request.post('/v1/merchant/config/updateMineConfig', data)
}

// 通过运营商获取【MineGame】配置
export function getOperatorMineGame(params: any) {
  return request({
    url: '/v1/merchant/config/getThirdMiniConfig',
    method: 'get',
    params: params
  }).then((res) => {
    res.data = new MineGameType().apiLocal(res.data)
    return res
  })
}
// 修改MineGame
export function editMineGame(data: any) {
  data = new MineGameType().localApi(data)
  return request({
    url: '/v1/merchant/config/updateThirdMiniConfig',
    method: 'put',
    data: data
  })
}

// 获取水位配置  
export const waterLevelList = (params: any) => {
  return request.get('/v1/merchant/configure/waterLevelList', { params: params })
}
// 修改水位配置  
export const changeWaterLevel = (data: any) => {
  return request.post('/v1/merchant/configure/changeWaterLevel', data)
}

// 批量修改游戏RTP
export function editRtpGame(data: any) {
  return request.post('/v1/merchant/config/agentChangeMoreRtp', data)
}
export function editRtpSwitch(data: any) {
  return request.post('/v1/merchant/config/updateMoreSwitch', data)
}
// 批量维护游戏
export function editMaintainGame(data: any) {
  return request.put('/v1/merchant/config/updateMoreGameStatus', data)
}
// 批量维护商户游戏
export function editAgentMaintainGame(data: any) {
  return request.put('/v1/merchant/config/switchThirdMiniConfig', data)
}
// 编辑游戏
export function editGame(data: any) {
  return request.post('/v1/merchant/config/updateGame', data)
}